function valiPro(pname,pimgsrc,pprice,pdescription,vnum,firstnum,secondnum){
  let errors = "";
  if(!(/^[\u4e00-\u9fa5A-Za-z0-9-_]{1,20}$/.test(pname))){
    errors = errors || {};
    errors.pname = "产品名称不得为空，只能使用中英文，数字，下划线，减号，且长度应在20字以内。";
  }
  if(!pimgsrc){
    errors = errors || {};
    errors.pimgsrc = "请上传相关产品图片。";
  }
  if(!(/^￥[0-9]{1,6}(.[0-9]{0,2})?$/.test(pprice))){
    errors = errors || {};
    errors.pprice = "产品价格不得为空，且在￥0.01~￥999999.99之间。";
  }
  if(!pdescription || pdescription.length > 100){
    errors = errors || {};
    errors.pdescription = "产品详情不得为空，且应在100字以内。";
  }
  if(!(Number(vnum) === firstnum + secondnum)){
    errors = errors || {};
    errors.vnum = "验证码输入有误，请重新输入。";
  }
  console.log(errors);
  return errors;
}

function showInfo(errors){
  if(errors){
    // console.log(errors);
    errors = JSON.parse(errors);
    if(errors.pname){
      pnameerror.innerText = errors.pname;
    }
    if(errors.pimgsrc){
      pimgsrcerror.innerText = errors.pimgsrc;
    }
    if(errors.pprice){
      ppriceerror.innerText = errors.pprice;
    }
    if(errors.pdescription){
      pdescriptionerror.innerText = errors.pdescription;
    }
    if(errors.vnum){
      vnumerror.innerText = errors.vnum;
    }
  }
}

if(typeof window === "undefined"){
  module.exports = valiPro;
}
